package com.org;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@MapperScan(basePackages = {"com.org.mapper"})
@EnableAsync
@EnableScheduling
@Slf4j
public class BootTestApplication {
    //注入配置值，注意@value的用法
    @Value("${this_port}")
    private  static String Port;

    public static void main(String[] args) {
//        SpringApplication.run(BootTestApplication.class, args);

        //也就是产生Spring容器
        //在控制台输入访问地址，不在log-spring里面配置

        //上下文需要启动类的泛型获取，否则加载为null
        ApplicationContext context = SpringApplication.run(BootTestApplication.class, args);//启动时获得当前的上下文容器
        String serverPort = context.getEnvironment().getProperty("server.port");
        log.info("人建词话 started at http://localhost:" + serverPort);
        System.out.println(serverPort);
        System.out.println(Port);
    }
}
